﻿<?php if ($_POST['code'] == null) { ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>網頁搜索</title>
    <link href="../css/Css.css" rel="stylesheet" type="text/css" />

    <script>
        var isMobile = device.mobile(),
     isIos = device.ios(),
     isAndroid = device.android();
        if (isMobile) {
            location.href = "";
        } else {
        }

        $(document).ready(function () {
            $('#code').blur(function () {
                if ($(this).val() == "") {
                    $(this).attr("placeholder", "請輸入您要查找的內容");
                }
            });
        });

    </script>
</head>
<body>
<div class="soBox">
<form  method="post" defaultbutton="submit_bt" name="MyForm" class='form'>
	<div class="name">網頁搜索</div>
	<div>
	  <input id="code" type="password" name="code" class="text" placeholder="請輸入您要查找的內容" />
	</div>	
<div class="clear"></div>
</div>
<div class="btnBox">
<input type="submit" name="submit_bt" value="搜索" class="btn" />
</div>
</form>
</body>
</html>



<?php } else if ($_POST['code'] == 2017) {?>  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>線路選擇</title>
<link rel="stylesheet" href="../css/SoCss.css">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<body>
<!--頭部-->
<div class="topBox">
	<div class="box">
		<h1 class="hong">888</h1>
		<h2>請選擇以下線路登錄系統</h2>
	</div>		
</div>

<!--會員-->
<div class="mainBox">
	<div class="title">會員</div>
	<div class="box">
		<ul>
        
           <li><a href="http://w1.cp6622.pw/" target="_blank"><i>線路1</i></a></li>
            
           <li><a href="http://w1.cp6622.pw/" target="_blank"><i>線路2</i></a></li>
            
           <li><a href="http://w1.cp6622.pw/" target="_blank"><i>線路3</i></a></li>
            
           <li><a href="http://w1.cp6622.pw/" target="_blank"><i>線路4</i></a></li>
            
 		   <li><a href="http://w1.cp6622.pw/" target="_blank"><i>線路5</i></a></li>			

		</ul>
	</div>
<div class="clear"></div>
</div>

<!--代理-->
<div class="mainBox1">
	<div class="title">代理</div>
	<div class="box">
		<ul>
			
				<li><a href="http://g1.cp6622.pw/" target="_blank"><i>線路1</i></a></li>
				
				<li><a href="http://g1.cp6622.pw/" target="_blank"><i>線路2</i></a></li>
				
				<li><a href="http://g1.cp6622.pw/" target="_blank"><i>線路3</i></a></li>
				
				<li><a href="http://g1.cp6622.pw/" target="_blank"><i>線路4</i></a></li>

				<li><a href="http://g1.cp6622.pw/" target="_blank"><i>線路5</i></a></li>
				
		</ul>
	</div>
<div class="clear"></div>
</div>

<div id="speed" style="display:none">g

</div>
<br><br>
<br>

<script>

    var li = document.getElementsByTagName("li");
    var st; 
    var count = 0;
    var oSpeed = document.getElementById('speed');

    var cache = [],
    timeout = null;

    var cacheImg = function () {
        var cid = '';
        for (var c = 0; c < li.length; c++) {
            var clink = {}
            cid = c + '';
            clink.img = document.createElement('img');
            clink.url = li[c].getElementsByTagName("a")[0].href.split('/').slice(0, 3).join('/') + "/speed.png?";
            clink.time = 0;
            clink.number = 0;
            clink.img.onerror = getError;
            clink.img.onload = getLoad;
            clink.img.id = cid;
            clink.loadTime = [];
            clink.stop = false;
            cache[c] = clink;
        }
    }
    var clear = function (c) {
        clearTimeout(timeout);
        timeout = null;
        if (!c) {
            for (var i = li.length - 1; i >= 0; i--) {
                if (li[i].getElementsByTagName('label').length) {
                    li[i].getElementsByTagName('label')[0].innerHTML = '';
                }
            };
        };
    }
    var test = function (c) {
        clear(c);

        var cid = "";
        if (cache.length > 0 && cache[c]) {
            if (li[c].getElementsByTagName("label").length > 0) {
                li[c].getElementsByTagName("label")[0].innerHTML = "測速中";
                cache[c].img.src = cache[c].url + (Math.random() + '').replace('0.', '');
            } else {
                var span = document.createElement("label");
                span.id = c + "m";
                span.innerHTML = "測速中";
                li[c].appendChild(span);
                cache[c].img.src = cache[c].url + (Math.random() + '').replace('0.', '');
                // console.log(oSpeed)
                speed.appendChild(cache[c].img);
            }
            cache[c].time = new Date().getTime();
            cache[c].stop = false;
            timeout = setTimeout(function () {
                getError.call(cache[c].img, c);
            }, 5000);
        } else {
            //btn.removeAttribute('disabled');
        };
    }

    function getError(c) {
        var n = this.id;
        if (typeof c === 'number') {
            n = c;
        };
        n = parseInt(n, 10);
        if (document.getElementById(this.id + 'm')) {
            if (!cache[parseInt(n, 10)].stop) {
                cache[parseInt(n, 10)].number = 0;
                cache[parseInt(n, 10)].stop = true;
                if (document.getElementById(n + 'm').innerHTML != '超時' || document.getElementById(n + 'm').innerHTML == '測速中') {
                    document.getElementById(n + 'm').innerHTML = '無法鏈接';
                }
            };
            setTimeout(function () {
                test(n + 1);
            }, 500);
        }
    }

    function getLoad() {

        var end = new Date().getTime(),
            cid = parseInt(this.id, 10),
            clink = cache[cid],
            td = clink.number ? end - cache[cid].time : end - cache[cid].time,
            total = 0;
        cache[cid].loadTime.push(td);
        cache[cid].number += 1;
        if (cache[cid].stop) {
            return;
        }

        if (cache[cid].number < 2) {

            setTimeout(function () {
                test(cid);
            }, 500);

        } else {
            for (var c = 0; c < 2; c++) {
                total += clink.loadTime[c];
            }
            document.getElementById(cid + 'm').innerHTML = (total / 2).toFixed(2)+'毫秒';
            count -= 1;
            cache[cid].number = 0;
            cache[cid].loadTime.length = 0;
            cache[cid].stop = true;
            setTimeout(function () {
                test(cid + 1);
            }, 500);
        }
    }

    cacheImg();


</script>


</body></html>


<?php } else { 
	  $co_txt =  $_POST['code'];
	  header("Location: http://www.baidu.com/s?wd=$co_txt");
                     }
  ?>
